"""
__author__ = 'heyanmin'
__time__ = '2021/8/23 5:33 下午'
"""
import collections


class Solution():

    # Counter获取各元素的个数，返回字典
    # 查找数组中出现次数大于数组长度一半的元素.次数多的是众数
    def majorityElement(self, nums):
        counts = collections.Counter(nums)
        return max(counts.keys())

    def majorityElement1(self, nums):
        nums.sort()
        print(len(nums))
        return nums[len(nums) // 2]


if __name__ == '__main__':
        s = Solution()
        nums = [1, 2, 3, 3, 3, 2,3]
        print(s.majorityElement1(nums))


